﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TJADRICD.Model;

namespace TJADRICD.CollaborativeDesignPlugin.Commission
{
   
    class CancelCommissionUser
    {
        public String UId;
        public String userId{ get;set; }
        public String userName { get; set; }
        public DateTime startDate { get; set; }
        public DateTime finishDate { get; set; }
        public int ComboxNameBoxIndex { get; set; }
    }


    class CommandCancelCommission
    {      
        private AuthorizeDao auDao = null;
        private AccountDao acDao = null;
        List<CancelCommissionUser> commissionedList = null;
       public  CommandCancelCommission()
         {
            auDao = new AuthorizeDao();
            acDao = new AccountDao();
            commissionedList = new List<CancelCommissionUser>();
        }
        public List<CancelCommissionUser> GetCommissionedList(String commissionId)
        {
            List<Authorize> auList = new List<Authorize>();
            auList = auDao.getAuthorListByUser(commissionId);

            foreach (Authorize auEntity in auList)
            {
                CancelCommissionUser user = new CancelCommissionUser();
                user.UId = auEntity.MajorId;
                user.userId = auEntity.AuthId;
                user.userName = acDao.getUserNameById(user.userId);
                user.startDate = auEntity.StartDate;
                user.finishDate = auEntity.FinishDate;
                commissionedList.Add(user);

            }


            return commissionedList;
        }

        public void DeleteCommissionRecord(CancelCommissionUser commissionedUser)
        {
            Authorize auEntity = new Authorize();
            auEntity.MajorId = commissionedUser.UId;
            auDao.deleteAuthorizeRecord(auEntity);
        }
    }
}
